package com.googlecode.jawb.tests.customtypes;

import com.googlecode.jawb.BinaryType;
import com.googlecode.jawb.clues.types.StaticLengthType;

public class CustomInteger implements StaticLengthType {
	@Override
	public Object fromByteArray(byte[] rawBytes) {
		int result = 0;
		
		for (byte val : rawBytes) {
			result += val;
		}

		return result;
	}

	@Override
	public int getAcceptedLength() {
		return 4;
	}

	@Override
	public byte[] toByteArray(Object object) {
		return BinaryType.UINT_32.toByteArray((Integer) object);
	}
}
